/**
 * @author Temdog007 / http://github.com/Temdog007
 */

import * as THREE from '../../js/threejs/build/three.module.js'

import {UIRow, UIText, UIInteger, UINumber} from '../../js/threejs/libs/ui.js'

import {SetGeometryCommand} from '../../js/threejs/commands/SetGeometryCommand.js'

var SidebarGeometryTetrahedronGeometry = function (editor, object) {
  var strings = editor.strings

  var signals = editor.signals

  var container = new UIRow()

  var geometry = object.geometry
  var parameters = geometry.parameters

  // radius

  var radiusRow = new UIRow()
  var radius = new UINumber(parameters.radius).onChange(update)

  radiusRow.add(new UIText(strings.getKey('sidebar/geometry/tetrahedron_geometry/radius')).setWidth('90px'))
  radiusRow.add(radius)

  container.add(radiusRow)

  // detail

  var detailRow = new UIRow()
  var detail = new UIInteger(parameters.detail).setRange(0, Infinity).onChange(update)

  detailRow.add(new UIText(strings.getKey('sidebar/geometry/tetrahedron_geometry/detail')).setWidth('90px'))
  detailRow.add(detail)

  container.add(detailRow)

  //

  function update() {
    editor.execute(new SetGeometryCommand(editor, object, new THREE.TetrahedronBufferGeometry(radius.getValue(), detail.getValue())))

    signals.objectChanged.dispatch(object)
  }

  return container
}

export {SidebarGeometryTetrahedronGeometry}
